import javax.swing.table.AbstractTableModel;


public class ResultTableModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String columnNames[] = { "Nazwa drogi", "Wycena", "Asekuracja" };
	
	private Object data [][];
	
	public ResultTableModel(int size) {
		data = new Object[size][3];
		data[0][0] = "Poki co";
		data[0][1] = "brak";
		data[0][2] = "drog";
	}

	@Override
	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public int getRowCount() {
		return data.length;
	}
	
	public String getColumnName(int col) {
        return columnNames[col];
    }

	@Override
    public Object getValueAt(int row, int col) {
        return data[row][col];
    }
	
	public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
	
	public void setData(Object[][] d){
		data = d;
	}
	
	public void addTrack(String name, String value, String secure) {
		for(int i=0; i<100; i++) {
			if(data[i][0] == null || (((String)data[i][0]).compareTo("Poki co") == 0)) {
				data[i][0] = name;
				data[i][1] = value;
				data[i][2] = secure;
				break;
			}
		}
		setData(data);
		
	}
	
	
}
